package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.member.vo.GoodsGrade;
import com.enation.app.javashop.model.trade.order.dto.OrderDetailDTO;
import com.enation.app.javashop.service.member.MemberCommentManager;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author fk
 * @version v2.0
 * @Description: 会员评论对外client
 * @date 2018/7/30 15:06
 * @since v7.0.0
 */
@RestController
@RequestMapping("/client/members/comments")
@Validated
@ApiIgnore
public class MemberCommentClientController {

    @Autowired
    private MemberCommentManager memberCommentManager;

    @GetMapping("/grades")
    public List<GoodsGrade> queryGoodsGrade() {

        return memberCommentManager.queryGoodsGrade();
    }

    @GetMapping("/count")
    public Integer getGoodsCommentCount(@RequestParam("goods_id") Long goodsId) {

        return memberCommentManager.getGoodsCommentCount(goodsId);
    }

    @PostMapping("/auto-good")
    public void autoGoodComments(@RequestBody List<OrderDetailDTO> detailDTOList) {
        memberCommentManager.autoGoodComments(detailDTOList);
    }

    @PutMapping("/edit-face/{member_id}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "member_id", value = "会员id", dataType = "int", paramType = "path", required = true),
            @ApiImplicitParam(name = "face", value = "头像", dataType = "String", paramType = "query", required = true)
    })
    public void updateLoginNum(@ApiIgnore @PathVariable("member_id") Long memberId, String face) {
        memberCommentManager.editComment(memberId, face);
    }

}
